package com.baidu.cloudmusic

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.baidu.cloudmusic.databinding.ActivityMainBinding
import com.baidu.lib_audio.AudioActivity
import com.baidu.lib_common_ui.base.BaseActivity
import com.baidu.lib_leancloud.LeanCloudManager
import com.bumptech.glide.Glide
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode

class MainActivity : BaseActivity<ActivityMainBinding>() {
    override fun initUI() {
        super.initUI()
        LeanCloudManager.instance.loadAdv { manager, results ->
            val adv = manager.getRandomAdv()
            Log.v("pxd", "adv = ${adv.image}")
            Glide.with(this).load(adv.image).into(mBinding.imageView)
        }

        LeanCloudManager.instance.loadCharts { manager, results ->
            results.forEach { chart ->
                manager.loadMusics(chart.id) { musicList ->
                    Log.v("pxd", chart.name)
                    musicList.forEach { music ->
                        Log.v("pxd", music.title)
                    }
                }
            }
        }
    }

}
